package org.anderground.editor.gui.properties;

import java.util.List;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JTabbedPane;

import org.anderground.core.model.Station;
import org.anderground.core.model.Tunnel;
import org.anderground.editor.gui.properties.line.LinePropertiesPanel;
import org.anderground.editor.gui.properties.station.StationsPropertiesPanel;
import org.anderground.editor.gui.properties.transfer.TransferPropertiesPanel;
import org.anderground.editor.gui.properties.tunnel.TunnelPropertiesPanel;

@SuppressWarnings("serial")
public class TabbedPropertiesPane extends JTabbedPane implements
		SelectionListener, Observer {

	private StationsPropertiesPanel stationsProperties = new StationsPropertiesPanel();
	private TunnelPropertiesPanel tunnelProperties = new TunnelPropertiesPanel();
	private TransferPropertiesPanel transferProperties = new TransferPropertiesPanel();
	private LinePropertiesPanel linePropertiesPanel = new LinePropertiesPanel();

	public TabbedPropertiesPane() {
		this.addTab("Stations", stationsProperties);
		this.addTab("Tunnels", tunnelProperties);
		this.addTab("Transfers", transferProperties);
		this.addTab("Lines", linePropertiesPanel);
	}

	@Override
	public void onSelectionChanged(List<Station> selectedStations,
			List<Tunnel> selectedTransitions) {
		stationsProperties.onSelectionChanged(selectedStations,
				selectedTransitions);
		tunnelProperties.onSelectionChanged(selectedStations,
				selectedTransitions);
		transferProperties.onSelectionChanged(selectedStations,
				selectedTransitions);
	}

	@Override
	public void update(Observable arg0, Object arg1) {
		stationsProperties.update(arg0, arg1);
		tunnelProperties.update(arg0, arg1);
		transferProperties.update(arg0, arg1);
		linePropertiesPanel.update(arg0, arg1);
	}

}
